package com.bwda.dsrs.filecenter.service.impl;


import com.bwda.dsrs.base.util.*;
import com.bwda.dsrs.filecenter.condition.DbScanTableHandleParams;
import com.bwda.dsrs.filecenter.domain.po.datasensitivewords.DataSensitiveWordsPo;
import com.bwda.dsrs.filecenter.domain.po.dbinfo.DbInfoPo;
import com.bwda.dsrs.filecenter.service.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

import java.sql.Connection;
import java.util.Date;
import java.util.List;


/**
 * @description:
 * @author: yangjun
 * @create: 2019-08-08 15:19
 */

@Service
public class AsyncServiceImpl implements AsyncService {
    private static final Logger logger = LoggerFactory.getLogger(AsyncServiceImpl.class);

    @Autowired
    private DbScanResultService dbScanResultService;

    /**
     * asyncServiceExecutor是前面ExecutorConfig.java中的方法名，
     * 表明executeAsync方法进入的线程池是asyncServiceExecutor方法创建的
     */
    @Override
    @Async("asyncServiceExecutor")
    public void executeAsync() {
        logger.info("我是一个异步方法，需要执行5秒：{}", DateUtil.formatDate(new Date(), DateUtil.FORMAT));
        try {
            Thread.sleep(5000);
        } catch (Exception e) {
            e.printStackTrace();
        }
        logger.info("执行结束：{}", DateUtil.formatDate(new Date(), DateUtil.FORMAT));

    }

    @Override
    @Async("asyncServiceExecutor")
    public void asyncScan(Integer dbid,Integer taskId,Integer taskHistoryId,Integer rowNum) {
        dbScanResultService.scan(dbid,taskId,taskHistoryId,rowNum);
    }

//    @Override
//    @Async("asyncServiceExecutor")
//    public void aysnHandle(DbScanTableHandleParams dbScanTableHandleParams){
//        dbScanResultService.tableHandle(dbScanTableHandleParams);
//    }


}

